<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8" %>
<html>
<head>
    <title>主页</title>
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/jquery-easyui-1.8.6/themes/default/easyui.css">
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/jquery-easyui-1.8.6/themes/icon.css">
    <script type="text/javascript" src="${pageContext.request.contextPath}/jquery-easyui-1.8.6/jquery.min.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/jquery-easyui-1.8.6/jquery.easyui.min.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/jquery-easyui-1.8.6/locale/easyui-lang-zh_CN.js"></script>
</head>
<body class="easyui-layout" data-options="fit:true">
<div data-options="region:'north'" style="height: 80px;background-color: #E0ECFF">
    <table style="width:100%;padding: 5px">
        <tr>
            <td style="width:50%">
                <img src="${pageContext.request.contextPath}/images/bglogo.png" alt="bglogo">
            </td>
            <td style="width:50%;vertical-align: bottom;text-align:right">
                <span style="font-size: 20px"><strong>欢迎：</strong>${currentUser.userName}</span>【${currentUser.trueName}】【${currentUser.roleName}】
            </td>
        </tr>
    </table>
</div>
<div data-options="region:'west',split:true,title:'导航菜单'" style="width: 200px">
    <div class="easyui-accordion" data-options="fit:true,border:false">
        <div title="营销管理" data-options="selected:true,iconCls:'icon-yxgl'" style="padding: 10px">
            <a href="javascript:openTab('营销机会管理','saleChanceManage.jsp','icon-yxjhgl')" class="easyui-linkbutton" data-options="plain:true,iconCls:'icon-yxjhgl'" style="width: 150px">营销机会管理</a>
            <a href="javascript:openTab('客户开发计划','cusdevplanManage.jsp','icon-yxjhgl')" class="easyui-linkbutton" data-options="plain:true,iconCls:'icon-khkfjh'" style="width: 150px">客户开发计划</a>
        </div>
        <div title="客户管理" data-options="iconCls:'icon-khgl'" style="padding:10px;">
            <a href="javascript:openTab('客户信息管理','customerManage.jsp','icon-khxxgl')" class="easyui-linkbutton" data-options="plain:true,iconCls:'icon-khxxgl'" style="width: 150px;">客户信息管理</a>
            <a href="javascript:openTab('客户流失管理','customerLossManage.jsp','icon-khlsgl')" class="easyui-linkbutton" data-options="plain:true,iconCls:'icon-khlsgl'" style="width: 150px;">客户流失管理</a>
        </div>
        <div title="服务管理" data-options="iconCls:'icon-fwgl'" style="padding:10px">
            <a href="javascript:openTab('服务创建','customerServiceCreate.jsp','icon-fwcj')" class="easyui-linkbutton" data-options="plain:true,iconCls:'icon-fwcj'" style="width: 150px;">服务创建</a>
            <a href="javascript:openTab('服务分配','customerServiceAssign.jsp','icon-fwfp')" class="easyui-linkbutton" data-options="plain:true,iconCls:'icon-fwfp'" style="width: 150px;">服务分配</a>
            <a href="javascript:openTab('服务处理','customerServiceProce.jsp','icon-fwcl')" class="easyui-linkbutton" data-options="plain:true,iconCls:'icon-fwcl'" style="width: 150px;">服务处理</a>
            <a href="javascript:openTab('服务反馈','customerServiceFeedback.jsp','icon-fwfk')" class="easyui-linkbutton" data-options="plain:true,iconCls:'icon-fwfk'" style="width: 150px;">服务反馈</a>
            <a href="javascript:openTab('服务归档','customerServiceFile.jsp','icon-fwgd')" class="easyui-linkbutton" data-options="plain:true,iconCls:'icon-fwgd'" style="width: 150px;">服务归档</a>
        </div>
        <div title="统计报表" data-options="iconCls:'icon-tjbb'" style="padding:10px">
            <a href="javascript:openTab('客户贡献分析','customerGxfx.jsp','icon-khgxfx')" class="easyui-linkbutton" data-options="plain:true,iconCls:'icon-khgxfx'" style="width: 150px;">客户贡献分析</a>
            <a href="javascript:openTab('客户构成分析','customerGcfx.jsp','icon-khgcfx')" class="easyui-linkbutton" data-options="plain:true,iconCls:'icon-khgcfx'" style="width: 150px;">客户构成分析</a>
            <a href="javascript:openTab('客户服务分析','customerFwfx.jsp','icon-khfwfx')" class="easyui-linkbutton" data-options="plain:true,iconCls:'icon-khfwfx'" style="width: 150px;">客户服务分析</a>
            <a href="javascript:openTab('客户流失分析','customerLsfx.jsp','icon-khlsfx')" class="easyui-linkbutton" data-options="plain:true,iconCls:'icon-khlsfx'" style="width: 150px;">客户流失分析</a>
        </div>
        <div title="基础数据管理" data-options="iconCls:'icon-jcsjgl'" style="padding:10px">
            <a href="javascript:openTab('数据字典管理','dataDicManage.jsp','icon-sjzdgl')" class="easyui-linkbutton" data-options="plain:true,iconCls:'icon-sjzdgl'" style="width: 150px;">数据字典管理</a>
            <a href="javascript:openTab('产品信息查询','productSearch.jsp','icon-cpxxgl')" class="easyui-linkbutton" data-options="plain:true,iconCls:'icon-cpxxgl'" style="width: 150px;">产品信息查询</a>
            <a href="javascript:openTab('用户信息管理','userManage.jsp','icon-user')" class="easyui-linkbutton" data-options="plain:true,iconCls:'icon-user'" style="width: 150px;">用户信息管理</a>
        </div>
        <div title="系统管理" data-options="iconCls:'icon-item'" style="padding:10px">
            <a href="javascript:openPasswordModifyDialog()" class="easyui-linkbutton" data-options="plain:true,iconCls:'icon-modifyPassword'" style="width: 150px;">修改密码</a>
            <a href="javascript:logout()" class="easyui-linkbutton" data-options="plain:true,iconCls:'icon-exit'" style="width: 150px;">安全退出</a>
        </div>
    </div>
</div>
<div data-options="region:'center'">
    <div class="easyui-tabs" id="tabs" data-options="fit:true,border:false">
        <div data-options="title:'首页',iconCls:'icon-home'">
            <div style="padding-top: 100px;text-align: center"><span style="color: red;font-size: 100px">欢迎使用</span></div>
        </div>
    </div>
</div>
<div data-options="region:'south'" style="height: 25px;padding: 5px;text-align: center">
    版权归高旭所有<a href="http://www.baidu.com" target="_blank">http://www.还未想好.com</a>(2020-)
</div>

<div id="dlg" class="easyui-dialog" style="width:400px;height:350px;padding: 10px 20px" closed="true" buttons="#dlg-buttons">
    <form id="fm" method="post">
        <table cellspacing="8px">
            <tr>
                <td>用户名：</td>
                <td><input class="easyui-textbox" id="userName" name="userName" readonly="readonly" value="${currentUser.userName }" style="width: 200px"/></td>
            </tr>
            <tr>
                <td>原密码：</td>
                <td><input class="easyui-passwordbox" id="oldPassword" name="oldPassword" required="true" style="width: 200px"/></td>
            </tr>
            <tr>
                <td>新密码：</td>
                <td><input class="easyui-passwordbox" id="newPassword" name="newPassword" required="true" style="width: 200px"/></td>
            </tr>
            <tr>
                <td>确认新密码：</td>
                <td><input class="easyui-passwordbox" id="newPassword2" name="newPassword2" required="true" style="width: 200px"/></td>
            </tr>
        </table>
    </form>
</div>

<div id="dlg-buttons">
    <a href="javascript:modifyPassword()" class="easyui-linkbutton" iconCls="icon-ok">保存</a>
    <a href="javascript:closePasswordModifyDialog()" class="easyui-linkbutton" iconCls="icon-cancel">关闭</a>
</div>
</body>
</html>

<script>
    function openTab(title, url, iconCls) {
        if ($("#tabs").tabs("exists", title)) {
            $("#tabs").tabs("select", title);
        } else {
            var content = "<iframe frameborder='0' style='width: 100%;height: 100%' src='${pageContext.request.contextPath}/page/" + url + "'></iframe>";
            $("#tabs").tabs("add", {
                title: title,
                iconCls: iconCls,
                closable: true,
                content: content
            });
        }
    }

    var url;

    function openPasswordModifyDialog() {
        url = "${pageContext.request.contextPath}/user/modifyPassword.do?id=${currentUser.id}";
        $("#dlg").dialog("open").dialog("setTitle", "修改密码");
    }

    function logout() {
        $.messager.confirm("系统提示", "您确定要退出系统吗？", function (r) {
            if (r) {
                window.location.href = '${pageContext.request.contextPath}/user/logout.do';
            }
        });
    }

    function closePasswordModifyDialog() {
        $("#dlg").dialog("close");
        $("#fm").form("reset");
    }

    function modifyPassword() {
        $("#fm").form("submit", {
            url: url,
            onSubmit: function () {
                var oldPassword = $("#oldPassword").passwordbox("getValue");
                var newPassword = $("#newPassword").passwordbox("getValue");
                var newPassword2 = $("#newPassword2").passwordbox("getValue");
                if (!$(this).form("validate")) {
                    return false;
                }
                if (oldPassword != '${currentUser.password}') {
                    $.messager.alert("系统提示", "用户原密码输入错误！");
                    return false;
                }
                if (newPassword != newPassword2) {
                    $.messager.alert("系统提示", "确认密码输入错误！");
                    return false;
                }
                return true;
            },
            success: function (result) {
                var result = eval('(' + result + ')');
                if (result.success) {
                    $.messager.alert("系统提示", "密码修改成功，下一次登录生效！");
                    $("#fm").form("reset");
                    $("#dlg").dialog("close");
                } else {
                    $.messager.alert("系统提示", "密码修改失败！");
                    return;
                }
            }
        });
    }

</script>
